# schemas/action_item.py
from typing import Union
from datetime import datetime
from pydantic import Field
from fastapi import Query

from admin.schemas.base import CamelModel


class ActionItemListIn(CamelModel):
    meeting_id: Union[int, None] = Field(default=None)
    status: Union[str, None] = Field(default=None)

    class Config:
        from_attributes = True
        field_operator_mapping = {
            "meeting_id": "=",
            "status": "=",
        }


class ActionItemDetailIn(CamelModel):
    id: int = Query(..., gt=0)


class ActionItemAddIn(CamelModel):
    meeting_id: int
    text: str
    assignee: Union[str, None] = None
    due_date: Union[datetime, None] = None


class ActionItemEditIn(ActionItemAddIn):
    id: int = Field(..., gt=0)


class ActionItemDelIn(CamelModel):
    id: int = Field(..., gt=0)


class ActionItemOut(CamelModel):
    id: int
    meeting_id: int
    text: str
    assignee: Union[str, None]
    due_date: Union[datetime, None]
    status: str
    created_at: Union[datetime, None]

    class Config:
        from_attributes = True
